package com.softeem.springbootdemo2.controller;

import com.softeem.springbootdemo2.entity.User;
import com.softeem.springbootdemo2.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZhouYu
 * @version 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/list")
    public List<User> list(){
        return userService.list();
    }

    @GetMapping("/add")
    public boolean add(User user){
        return userService.save(user);
    }

    @GetMapping("/update")
    public boolean update(User user){
        return userService.updateById(user);
    }

    @GetMapping("/{id}")
    public boolean delete(@PathVariable Integer id){
        return userService.removeById(id);
    }

}
